package edu.csl.study.springboot.eventDemo.spring.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;


@Service
public class PublisherService {

    @Autowired
    ApplicationContext applicationContext;

    public void pay(int newStatus, String msg) {
        PaymentInfo paymentInfo = new PaymentInfo(newStatus, msg);
        PaymentStatusUpdateEvent paymentStatusUpdateEvent = new PaymentStatusUpdateEvent(paymentInfo);
        applicationContext.publishEvent(paymentStatusUpdateEvent);
    }
}
